@use './themes/light.scss';
@use './themes/dark.scss';
@use 'normalize.scss';
@use '@/style/schemaForm.scss';
@use "sass:math";

@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: normal;
  src: url(../assets/fonts/Roboto-Regular.ttf) format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 700;
  src: url(../assets/fonts/Roboto-Bold.ttf) format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 900;
  src: url(../assets/fonts/Roboto-Black.ttf) format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: italic;
  font-weight: normal;
  src: url(../assets/fonts/Roboto-Italic.ttf) format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: italic;
  font-weight: 700;
  src: url(../assets/fonts/Roboto-BoldItalic.ttf) format('truetype');
}
@font-face {
  font-family: 'Roboto';
  font-style: italic;
  font-weight: 900;
  src: url(../assets/fonts/Roboto-BlackItalic.ttf) format('truetype');
}

$font: Roboto, -apple-system, BlinkMacSystemFont, PingFang SC, Hiragino Sans GB, Helvetica Neue,
  Helvetica, Arial, sans-serif;

body {
  padding: 0;
  margin: 0;
  color: var(--el-text-color-primary);
  font-size: 14px;
  font-family: $font;
  background-color: var(--color-bg);
}

* {
  box-sizing: border-box;
}

a {
  color: var(--el-color-primary);
  text-decoration: none;
  background-color: transparent;
  outline: none;
  cursor: pointer;
  -webkit-transition: color 0.3s;
  transition: color 0.3s;
}

textarea,
code {
  font-family: $font;
}

img {
  max-width: 100%;
}

h1 {
  font-size: 22px;
  color: var(--color-title-primary);
}
h2 {
  font-size: 18px;
  color: var(--color-title-primary);
  margin-top: 14px;
  margin-bottom: 24px;
}
h3 {
  font-size: 16px;
}
p.tip {
  margin: 0px;
  color: var(--color-text-secondary);
}
p.description {
  line-height: 1.8;
}

#app {
  min-width: 600px;
  margin: 0 auto;
}

#nprogress {
  .bar {
    background: linear-gradient(135deg, #0ad18e 0%, #03a4a5 100%);
  }
}

.container {
  height: 100%;
}

.detail-top {
  padding: 0 24px;
}
.app-wrapper {
  padding: 0 24px;
  &.with-padding-top {
    padding-top: 32px;
  }
}

.app-wrapper-compact {
  padding: 15px 10px;
}

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar:horizontal {
  height: 6px;
}
::-webkit-scrollbar:vertical {
  height: 6px;
}
::-webkit-scrollbar-track {
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background-color: #0003;
  border-radius: 10px;
  transition: all 0.2s ease-in-out;
}
::-webkit-scrollbar-thumb:hover {
  cursor: pointer;
  background-color: #0000004d;
}

.search-wrapper {
  background-color: var(--color-bg-details);
  padding: 16px 24px 32px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--color-border-card);
  &.without-padding-top {
    padding-top: 0;
  }
  .el-button {
    margin-left: 12px;
  }
  & > .el-col {
    > .el-button:first-child {
      margin-left: 0;
    }
  }
  .el-col {
    margin-top: 16px;
  }
  .el-select {
    width: 100%;
  }
  .el-date-editor {
    width: 100%;
  }
  .col-oper {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
  }
}

.emq-table-footer {
  display: flex;
  margin-top: 30px;
  margin-bottom: 28px;
  justify-content: flex-end;
}

.page-header-title {
  font-size: 18px;
  color: var(--color-title-primary);
  font-weight: 600;
  margin-bottom: 24px;
}

.field-info {
  margin: 0;
  list-style: none;
  padding: 3px 0;
  line-height: 35px;

  .field-title {
    display: inline-block;
    font-style: normal;
    font-size: 14px;
    color: #999;
    padding-right: 16px;
  }

  .field-value {
    font-size: 14px;
    color: #101010;
  }
}

// Text-align button group
.button-group {
  margin-top: 24px;
  &__center {
    text-align: center;
  }
  &__right {
    text-align: right;
  }
}

.el-button.icon-button {
  font-size: 18px;
}
.enable-btn {
  margin-right: 12px;
}

.g-coap::before {
  background-image: url('~@/assets/gateway/coap.png');
}
.g-lwm2m::before {
  background-image: url('~@/assets/gateway/lwm2m.png');
}
.g-mqttsn::before {
  background-image: url('~@/assets/gateway/mqttsn.png');
}
.g-stomp::before {
  background-image: url('~@/assets/gateway/stomp.png');
}
.g-tcp::before {
  background-image: url('~@/assets/gateway/tcp.png');
}
.g-exproto::before {
  background-image: url('~@/assets/gateway/exproto.png');
}

.section-header {
  font-size: 18px;
  color: var(--color-title-primary);
  font-weight: 600;
  margin-top: 32px;
  padding-bottom: 24px;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  &:not(:first-of-type) {
    margin-top: 16px;
  }

  & .section-desc {
    font-size: 14px;
    font-weight: normal;
    color: #999;
    margin: 5px 0;
  }

  & > :first-child {
    display: flex;
    align-items: center;
    flex-grow: 1;
    overflow: hidden;
  }

  & > :not(:first-child) {
    margin-left: 10px;
  }

  span,
  i {
    vertical-align: middle;
  }
}

.part-header {
  color: var(--color-title-primary);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  &:not(:first-of-type) {
    margin-top: 30px;
  }
}

.bold {
  font-weight: 600;
}

.no-dropdown-arrow {
  .popper__arrow {
    display: none;
  }
}

.el-input-group--append .el-input-group__append {
  width: 120px;
  padding: 0;
  .el-select {
    margin: -10px 0;
  }
}
.el-input-group--prepend .el-input-group__prepend {
  width: 120px;
  padding: 0;
  .el-select {
    margin: -10px 0;
  }
}
input:disabled {
  -webkit-text-fill-color: var(--el-disabled-text-color);
  -webkit-opacity: 1;
  opacity: 1;
  color: var(--el-disabled-text-color);
}

.el-button.link-btn {
  padding: 0;
  a {
    display: flex;
    align-items: center;
    padding: 9px 15px;
    color: inherit;
  }
}
.el-button.el-button--primary.confirm-danger {
  color: var(--el-color-danger);
  background: var(--el-color-danger-light-9);
  border: 1px solid var(--el-color-danger-light-5);
  &:hover {
    color: var(--el-color-white);
    background: var(--el-color-danger);
    border-color: var(--el-color-danger);
  }
}

.el-date-editor {
  --el-date-editor-datetimerange-width: 100%;
}

.text-status {
  &.success {
    color: var(--el-color-primary);
  }
  &.warning {
    color: var(--el-color-warning);
  }
  &.danger {
    color: var(--el-color-danger);
  }
}

.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
.iconfont {
  font-size: 21px;
  color: var(--color-title-primary);
}

.el-select .el-input .el-input__suffix .el-input__validateIcon {
  display: none;
}

.el-form-item.label-whole-line {
  .el-form-item__label {
    position: relative;
    width: 100%;
  }
}

.el-form-item__content {
  p.value {
    margin: 0;
    color: var(--color-text-secondary);
    padding-left: 12px;
    word-break: break-all;
  }
}

.form-item-desc {
  margin-left: 4px;
  font-size: 14px;
  cursor: pointer;
}

.form-item-desc-popper {
  width: 300px;
}

.monaco-container {
  height: 300px;
  border: 1px solid var(--color-border-primary);
  width: 100%;
  &.is-small {
    height: 200px;
  }
}

.block {
  margin-bottom: 24px;
}
.block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.el-card.table-card {
  margin-bottom: 26px;
  .el-table {
    border-top-left-radius: 0px;
    border-top-right-radius: 0px;
    .el-table__inner-wrapper:after {
      content: none;
    }
    &:after,
    &:before {
      top: 0;
      height: 100%;
    }
    .el-table__cell {
      padding: 8px 12px;
    }
    th.el-table__cell > .cell {
      font-size: 16px;
    }
    th.el-table__cell.is-sortable {
      padding: 8px 5px !important;
    }
  }
  .el-card__body {
    padding: 0px;
    padding-top: 4px;
  }
}
.el-tabs.detail-tabs {
  .el-tabs__header {
    background-color: var(--color-bg-details);
    padding: 0 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--color-border-primary);
    .el-tabs__item.is-active {
      border-bottom: 1px solid var(--color-border-card);
    }
  }
  .app-wrapper {
    padding-top: 0px;
  }
}
.el-card {
  &.app-card {
    margin-bottom: 24px;
  }
  .el-tabs.detail-tabs {
    .el-tabs__header {
      margin-bottom: 24px;
      .el-tabs__item.is-active {
        border-bottom: 1px solid var(--color-bg-content);
      }
    }
  }
}
.block-title {
  margin-top: 0;
  margin-bottom: 0;
  margin-right: 12px;
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  color: var(--color-title-primary);
}

.space-between {
  display: flex;
  justify-content: space-between;
}

.vertical-align-center {
  display: flex;
  align-items: center;
}

@keyframes scaleAnimate {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

.running-status,
.stop-status {
  position: relative;
  padding: 0 6px;
}
.running-status::before,
.running-status::after,
.stop-status::before,
.stop-status::after {
  position: absolute;
  content: '';
  border-radius: 50%;
}
.running-status::before {
  left: -14px;
  top: 0px;
  width: 18px;
  height: 18px;
  background-color: #00b17350;
  animation: scaleAnimate 1.5s ease-out infinite;
}
.running-status::after {
  width: 6px;
  height: 6px;
  background-color: #00b173;
  top: 6px;
  left: -8px;
  z-index: 3;
}

.stop-status::after {
  width: 6px;
  height: 6px;
  background-color: #e44242;
  top: 6px;
  left: -11px;
  z-index: 3;
}

.resource-item-overview {
  p {
    margin-top: 0;
    margin-bottom: 0;
  }
  .overview-sub-block {
    margin-bottom: 28px;
  }
  .el-card {
    &.success-bg {
      background-color: rgba(0, 168, 143, 0.1);
    }
    &.failed-bg {
      background-color: rgba(118, 119, 137, 0.1);
    }
    &.matched-bg {
      background-color: rgba(93, 78, 255, 0.1);
    }
    &.rate-bg {
      background-color: rgba(61, 127, 249, 0.1);
    }
    &.no-result-bg {
      background-color: rgba(13, 91, 97, 0.1);
    }
    &.last-five-rate-bg {
      background-color: rgba(103, 206, 218, 0.1);
    }
    &.max-rate-bg {
      background-color: rgba(191, 115, 255, 0.1);
    }
  }
  .overview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: bold;
    p {
      color: var(--color-title-primary);
    }
  }
  .card-hd {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 16px;
    .el-icon {
      cursor: pointer;
      font-size: 18px;
      padding-top: 2px;
    }
  }
  .card-sub-desc {
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--el-text-color-secondary);
    line-height: 20px;
  }
  .rule-statistic {
    .el-col {
      padding-bottom: 20px;
    }
  }
  .statistic-label {
    margin-bottom: 20px;
  }
  .statistic-num {
    $height: 25px;
    min-height: $height;
    line-height: $height;
    font-size: 24px;
    font-weight: 600;
    color: var(--color-title-primary);
    .unit {
      font-size: 16px;
      margin-left: 4px;
      font-weight: normal;
    }
  }
  .text-status {
    margin-right: 8px;
  }
}

.table-with-draggable {
  tbody {
    tr {
      cursor: move;
    }
  }
}

.pointer {
  cursor: pointer;
}

.table-dropdown-btn {
  padding: 1px 9px;

  .icon-arrow {
    vertical-align: top;
    margin-left: 4px;
    &.rotate {
      transform: rotate(180deg);
    }
  }
}

.table-dropdown-popper {
  .el-dropdown-menu__item {
    &.disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }
    &.danger {
      color: #e34242;
    }
  }
}

.table-data-without-break {
  display: block;
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.first-column-with-icon-type {
  display: flex;
  align-items: center;
  .icon-type {
    width: 48px;
    height: 48px;
    margin-right: 6px;
  }
  .name-type-block {
    line-height: 2;
  }
  .name-data {
    display: block;
    line-height: 16px;
    color: var(--el-color-primary);
  }
  .type-data {
    font-size: 14px;
    color: var(--color-text-secondary);
    line-height: 16px;
  }
}

.with-dividing-line-bottom {
  position: relative;
  &::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    display: block;
    width: 100%;
    height: 1px;
    background-color: var(--color-border-primary);
  }
}

.collapse-border {
  $collapse-border: 1px solid var(--color-border-primary);
  border-top: $collapse-border;
  .el-collapse-item__header {
    min-height: var(--el-collapse-header-height);
    height: auto;
    padding: 4px 0 4px 16px;
    border-bottom: $collapse-border;
    &.is-active {
      border-bottom: $collapse-border;
    }
  }
  .el-collapse-item {
    border-right: $collapse-border;
    border-left: $collapse-border;
  }
  .el-collapse-item__content {
    padding: 16px 16px;
    section {
      margin-bottom: 16px;
    }
  }
}

.el-col.col-need-row {
  // To squeeze the next column down
  margin-right: 40%;
}

.keep-spaces {
  white-space: pre-wrap;
}

code {
  padding: 0.25rem 0.5rem;
  margin: 0;
  color: var(--color-text-mdcode);
  font-size: .85em;
  border-radius: 3px;
  background-color: var(--color-bg-mdcode);
  font-family: Menlo, Monaco, Consolas, Courier New, monospace;
}

[data-theme='dark'] {
  .img-black {
    filter: invert(1);
  }
}

.border-checkbox {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--color-border-primary);
  padding: 12px;
  .checkbox-note {
    margin: 0px;
    padding-left: 21px;
    font-size: 13px;
    color: var(--color-text-footer);
    line-height: 1.6;
    word-break: break-word;
  }
}

.overview-visible {
  overflow: visible;
}

.node-status-dot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 4px;
  &.is-running,
  &.is-success {
    background: var(--color-primary);
  }
  &.is-stopped {
    background: var(--color-text-placeholder);
  }
  &.is-danger {
    background: var(--el-color-danger);
  }
  &.is-warning {
    background: var(--el-color-warning);
  }
}
/* FLOW */
.flow {
  .node-item {
    padding: 9px 16px 9px 9px + 16px;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 22px;
    border-radius: 8px;
    border-style: solid;
    background: var(--color-bg-content);

    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      box-sizing: border-box;
      width: 20px;
      height: 100%;
      border-width: 0px 10px;
      border-style: solid;
      border-right-color: transparent;
      border-top-left-radius: 7px;
      border-bottom-left-radius: 7px;
    }

    &.node-source {
      &::before {
        border-left-color: #00b173;
      }
    }

    &.node-processing {
      &::before {
        border-left-color: #469cf7;
      }
    }

    &.node-sink {
      &::before {
        border-left-color: #906ef2;
      }
    }
    img.is-scaled-up {
      transform: scale(1.5);
    }
  }

  // To increase the weight
  .node-item,
  .vue-flow .node-item {
    border-width: 1px;
    border-color: var(--color-bg-mdcode);
  }

  .editor {
    .vue-flow__node {
      box-sizing: border-box;
      padding: 8px 16px;
    }

    .vue-flow__node.is-disabled {
      filter: grayscale(1);
      opacity: 0.7;
    }
  }

  $handle-size: 8px;
  .vue-flow__handle {
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: content-box;
    width: $handle-size;
    height: $handle-size;
    border: none;
    .icon-add {
      display: none;
      color: #fff;
      font-weight: 600;
      pointer-events: none;
    }
  }

  .vue-flow__handle-left {
    left: math.div(-$handle-size, 2)
  }

  .vue-flow__handle-right {
    right: math.div(-$handle-size, 2)
  }

  .vue-flow__handle {
    --vf-handle: #babcbe;
  }
}
